package com.example.soapserver.endpoint;

import com.example.soapserver.model.pending.GetPendingWorksResponse;
import com.example.soapserver.model.pending.PendingWorksRequest;
import com.example.soapserver.service.PendingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;
import org.springframework.ws.server.endpoint.annotation.RequestPayload;
import org.springframework.ws.server.endpoint.annotation.ResponsePayload;

@Endpoint
public class PendingEndpoint {
    private static final String NAMESPACE_URI = "http://com.cssc.cn/webservice/pending";

    private final PendingService pendingService;

    @Autowired
    public PendingEndpoint(PendingService pendingService) {
        this.pendingService = pendingService;
    }


    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "pendingWorksRequest")
    @ResponsePayload
    public GetPendingWorksResponse getAllPending(@RequestPayload PendingWorksRequest request) {
        GetPendingWorksResponse response = new GetPendingWorksResponse();
        response.getPendingWorks().addAll(pendingService.getAll());
        return response;
    }



}